<?php
include_once('common/header.php');
if($AppUI->id <= 0 || (isset($_SESSION['event']) && ($_SESSION['event'] <= 0))) {
	$this->_redirect(HOST_BACKEND);
}
$intStatus		= $objRequest->getParam('stt', -1);
$intCategoryId	= $objRequest->getParam('cate', 0);
$intOption		= $objRequest->getParam('opt', 0);
$strKey			= $objRequest->getParam('key', '');
$strStart		= $objRequest->getParam('startdate', '');
$strEnd			= $objRequest->getParam('enddate', '');
$intPage		= $objRequest->getParam('page', 1);
$intCancel		= $objRequest->getParam('pcancel', 0);
$intLimit		= $variable['ADMIN_LIMIT']['val'];
$intOff			= (($intPage-1) * $intLimit);
$intTotal		= 0;
if($intCancel) {
	if(isset($_SESSION['EVENT_SEARCH'])) unset($_SESSION['EVENT_SEARCH']);
	if(isset($_SESSION['EVENT_CANCEL'])) unset($_SESSION['EVENT_CANCEL']);
	$intLanguage	= 0;
	$intStatus		= -1;
	$intOption		= 0;
	$intCategoryId	= 0;
	unset($strKey);
	unset($strStart);
	unset($strEnd);
}
$objCategory	= new Category();
$objEvent		= new Event(); 
$arrResult		= $objEvent->getAll($AppUI->type, 
									$intCategoryId, 
									$intStatus, 
									$intOption, 
									$strKey, 
									Ecore_Function::convertStrToDate($strStart), 
									Ecore_Function::convertStrToDate($strEnd), 
									$intOff, 
									$intLimit, 
									$intTotal
								);
if($intCategoryId != 0 || $intOption != 0 || $strKey != '' || $strStart != '' || $strEnd != '') {
	$_SESSION['EVENT_CANCEL'] 	= 1;	
	$_SESSION['EVENT_SEARCH']	= $objRequest->getParams();
}
else {
	if(isset($_SESSION['EVENT_SEARCH'])) unset($_SESSION['EVENT_SEARCH']);
	if(isset($_SESSION['EVENT_CANCEL'])) unset($_SESSION['EVENT_CANCEL']);
}
# list
$this->view->arrResult		= $arrResult;
$this->view->intTotal		= $intTotal;
$this->view->intOffset		= $intOff;
$this->view->intLimit		= $intLimit;
$this->view->arrOption		= $arrOption;
$this->view->strUrl			= Ecore_Function::getUrl(HOST_BACKEND);
$this->view->arrStatus		= ($AppUI->type == ROOT_ROLE) ? $arrStatusAd : $arrStatus;
$this->view->intStatus		= $intStatus;
$this->view->arrCategory	= $objCategory->getParent(EVENT_TYPE);
